package com.hzlj.position.locate.dao;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fz.common.base.converter.QueryWrapperConverterPlus;
import com.hzlj.position.locate.common.dto.reportSync.ReportSyncQueryParamDTO;
import com.hzlj.position.locate.common.dto.reportSync.ReportSyncQueryResultDTO;
import com.hzlj.position.locate.common.model.ReportSync;
import com.hzlj.position.locate.mapper.ReportSyncMapper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * 通信联络核查-同步配置表(ReportSync)表操作类
 *
 * @author lifh
 * @date 2023-03-13 19:10:15
 */
@Repository
public class ReportSyncDao extends ServiceImpl<ReportSyncMapper, ReportSync> {
    @Resource
    private ReportSyncMapper reportSyncMapper;


    /**
     * 查询列表：不分页
     *
     * @param dto 查询条件
     * @return 对象列表
     */
    public List<ReportSyncQueryResultDTO> listReportSync(ReportSyncQueryParamDTO dto) {
        return QueryWrapperConverterPlus.of(reportSyncMapper)
                .list(ReportSyncQueryResultDTO.class, dto);
    }

    public boolean updateReportSync(ReportSync sync) {
        LambdaUpdateWrapper<ReportSync> updateWrapper = new UpdateWrapper<ReportSync>().lambda()
                .eq(ReportSync::getJgCode, sync.getJgCode())
                .eq(ReportSync::getSyncType, sync.getSyncType());
        return this.update(sync, updateWrapper);
    }
}

